<div>
	<?php echo $this->partial( 'partials/recipe.phtml', $this->recipe ) ?>
 
	<!-- Ingredients -->
	<div id="ingredients-summary">
		<div>
			<h3>Ingredients</h3>
			<ul>
			<?php foreach ($this->ingredients as $ingredient ): ?>
			<?php echo $this->partial( 'partials/ingredient.phtml', $ingredient ); ?>
			<?php endforeach; ?>
			</ul>
		</div>
		<?php if ($this->checkOwner($this->recipe['user_id']) ): ?>
		<div>	
			<p><a href="<?= $this->url( array( 
				'controller' => 'ingredient', 
				'action' => 'new',
				'recipe_id' => $this->recipe['id']
			), 'default', true ); ?>">
			Add another ingredient?</a></p>
		</div>
		<?php endif; ?>
	</div>
	<!-- End of Ingredients -->
	
	<!-- Methods -->
	<a name="methods"></a>
	
	<?php if ($this->checkOwner($this->recipe['user_id']) ): ?>
	<script type="text/javascript">
	$(function() {
		$(".sortable").sortable({
			update: function(event, ui) {
				var order = $("#sortable").sortable("serialize");
				alert(order);
				$.post("/ajax/method-sort/", order, function(theResponse){
					$("#contentRight").html(theResponse);
				});
			}
		});
		$(".sortable").disableSelection();
	});
	</script>
	<?php endif; ?>
	
	<div>
		<h3>Method</h3>
	
		<ul class="sortable">
	<?php foreach ($this->methods as $method): ?>
			<li id="method_<?php echo $method['id'] ?>" class="ui-state-default">
			<?php if ($this->checkOwner($this->recipe['user_id']) ): ?>
			<span class="ui-icon ui-icon-arrowthick-2-n-s"></span>
			<a href="<?= $this->url( array( 
				'controller' => 'method', 
				'action' => 'edit',
				'id' => $method['id']
			), 'default', true ); ?>"><img title="Edit" src="/images/icons/pencil.png" alt="Edit"/></a>
			&nbsp;
			<a href="<?= $this->url( array( 
				'controller' => 'method', 
				'action' => 'delete',
				'id' => $method['id']
			), 'default', true ); ?>"><img title="Delete" src="/images/icons/cross.png" alt="Delete"/></a>
			<?php endif; ?>
			<?php echo $this->escape( $method['description'] ); ?>
			</li>
	<?php endforeach; ?>
		</ul>
		<?php if ($this->checkOwner($this->recipe['user_id']) ): ?>
		<div>
			<p><a href="<?= $this->url( array( 
				'controller' => 'method', 
				'action' => 'new',
				'recipe_id' => $this->recipe['id']
			), 'default', true ); ?>">
			Add another method?</a></p>
		</div>
		<?php endif; ?>
	</div>
	<!-- End of Methods -->
	
	<!-- Rating -->
	<a name="ratings"></a>
	<div>
		<h3>Last 5 Ratings</h3>		
		<?php foreach ($this->ratings as $rating): ?>
		<div>
		<?php echo $rating['comment'] . ' '. $rating['value'] ?>/10 by
			<a href="<?= $this->url( array( 
				'controller' => 'user', 
				'action' => 'view',
				'id' => strtolower($rating['username'])
			), 'default', true ); ?>"><?php echo $rating['username']; ?></a>
			<small><?php echo $rating['created'] ?></small>
			<?php if ($this->checkOwner($rating['user_id']) ): ?>
			<a href="<?= $this->url( array( 
				'controller' => 'rating', 
				'action' => 'delete',
				'recipe_id' => $rating['recipe_id'],
				'user_id' => $rating['user_id'],
			), 'default', true ); ?>"><img title="Delete" src="/images/icons/cross.png" alt="Delete"/></a>
			<?php endif; ?>
		</div>
		<?php endforeach; ?>
		<?php if (! $this->checkOwner($this->recipe['user_id']) && ! $this->hasRated ): ?>
		<?php echo $this->rating_form ?>
		<?php endif; ?>
	</div>
	<!-- End of Ratings -->
	
	<!-- Comments -->
	<a name="comments"></a>
	<div>
		<h3>Comments</h3>
		<?php foreach ($this->comments as $comment): ?>
		<div>
			<?php echo $comment['comment'] ?> by
			<a href="<?= $this->url( array( 
				'controller' => 'user', 
				'action' => 'view',
				'id' => strtolower($comment['username'])
			), 'default', true ); ?>"><?php echo $comment['username']; ?></a>
			<small><?php echo $comment['created'] ?></small>
			<?php if ($this->checkOwner($comment['user_id']) ): ?>
			<a href="<?= $this->url( array( 
				'controller' => 'comment', 
				'action' => 'delete',
				'recipe_id' => $comment['recipe_id'],
				'id' => $comment['id'],
			), 'default', true ); ?>"><img title="Delete" src="/images/icons/cross.png" alt="Delete"/></a>
			<?php endif; ?>
		</div>
		<?php endforeach; ?>
		<?php echo $this->comment_form ?>
	</div>
	<!-- End of Comments -->
	
</div>